<div class="main-content">
	<div class="main-content-inner">
		<div class="breadcrumbs" id="breadcrumbs">
			<ul class="breadcrumb">
				<li><i class="ace-icon fa fa-home home-icon"></i> <a>首页</a></li>
				<li class="active">需购设备</li>
			</ul>
		</div>
		<div class="tabbable">
			<ul class="nav nav-tabs padding-12 tab-color-blue background-blue"
				id="myTab4">
				<li class="active"><a data-toggle="tab" href="#home4" onclick="getNeedItemsInfo(1)"
					aria-expanded="true">需购设备信息</a></li>
				<li class=""><a data-toggle="tab" href="#profile4"
					aria-expanded="false">需购设备添加</a></li>
			</ul>
			<div class="tab-content">
				<div id="home4" class="tab-pane active">
					<!-- 第一个标签 -->
						<div class="row">
						<div class="col-xs-12">
							<div id="dynamic-table_wrapper"
								class="dataTables_wrapper form-inline no-footer">
								<div class="row" style="height: 50px;">
									<div class="col-xs-5">
										<a style="cursor: pointer;" onclick="downloadNeedItemsWord();">需购设备申请表下载</a>
									</div>
									<div class="nav-search col-xs-7" >
										<span class="input-icon" style="float: right;">
											<button onclick="getNeedItemsInfo(1);" type="button"  class="btn btn-info btn-sm" style="float: right;">
											查询
											</button>
										</span>
										<span class="input-icon" style="float: right;"> <input
											style="float: left;" type="text" placeholder="关键字查询 "
											class="nav-search-input" onkeyup="getNeedItemsInfo(1)"
											id="search_input" autocomplete="off"> <i
											class="ace-icon fa fa-search nav-search-icon"></i>
										</span>
										<span class="input-icon" style="float: right;"> 
											<input class="nav-search-input" placeholder="截止日期"
													id="LAY_demorange_e" >
										</span>
										<span class="input-icon" style="float: right;"> 
											<input class="nav-search-input" placeholder="开始日期"
													id="LAY_demorange_s" >
										</span>
									</div>
								</div>
								<table
									class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable"
									id="dynamic-table" role="grid"
									aria-describedby="dynamic-table_info">
									<thead>
										<tr>
											<th class="col-xs-1">设备名称</th>
											<th class="col-xs-1">类别</th>
											<th class="col-xs-1">型号</th>
											<th class="col-xs-1">需购数量</th>
											<th class="col-xs-1">经办人</th>
											<th class="col-xs-2">
												审核状态
												<select name="interest" onchange="getNeedItemsInfo(1);" id="status_select" lay-filter="aihao">
													<option value="2">全部</option>
													<option value="0">待审核</option>
													<option value="1">通过</option>
													<option value="-1">驳回</option>
													<option value="-2">已购</option>
												</select>
											</th>
											<th class="col-xs-1.5">购置日期</th>
											<th class="col-xs-2.5">操作</th>
										</tr>
									</thead>
									<tbody id="itemsPage">
									</tbody>
								</table>
								<!-- 分页 -->
								<hr>
								<div id="page5" style="float: right;"></div>
							</div>
						</div>
					</div>
				</div>
				<div id="profile4" class="tab-pane">
					<!-- 第二个标签 -->
					<div class="row">
						<div class="col-xs-12">
							<div class="alert alert-info">
								<i class="ace-icon fa fa-hand-o-right"></i>
								如果您需要添加单条数据，点击添加按钮；如果您需要批量添加数据，请先下载使用说明，模板填写完毕后，拖拽到上传界面即可。
								<button class="close" data-dismiss="alert">
									<i class="ace-icon fa fa-times"></i>
								</button>
							</div>
							<div id="dynamic-table_wrapper"
								class="dataTables_wrapper form-inline no-footer">
								<div class="row">
									<div class="col-xs-6">
										<a style="cursor: pointer;" onclick="downloadTemplate('0');">模板使用说明</a>&nbsp;&nbsp;&nbsp;
										<a style="cursor: pointer;" onclick="downloadTemplate('3');">模板下载</a>
									</div>
									<div class="col-xs-6" >
										<button onclick="addNeedItem();" id="addNeedItem_btn" type="button" class="btn btn-info btn-sm" style="float: right;">
											添加
										</button>
									</div>
								</div>
							</div>
							<div>
								<form action="need/uploadFileWithNeedItemsExcel"
									class="dropzone" id="dropzone">
									<div class="fallback">
										<input name="file" type="file" multiple="" />
									</div>
								</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- 添加设备弹框 -->
<div id="addNeedItemContent" hidden="hidden" >
	<form id="addNeedItemform" action="#" method="post">
		<div class="col-xs-12">&nbsp;</div>
		<div class="col-xs-12">
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">设备名称</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="items.name" placeholder="必填" maxlength="30" />
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">设备类别</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="items.type" placeholder="必填" maxlength="30"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">设备型号</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="items.modelNum" placeholder="必填" maxlength="30"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">规格</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="items.norms" placeholder="必填" maxlength="30"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">单价（元）</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="need_items.price" placeholder="必填" onkeyup="value=value.replace(/[\W]/g,'')" maxlength="6"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">需购数量</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="need_items.number" placeholder="必填" onkeyup="value=value.replace(/[\W]/g,'')" maxlength="10"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">购置日期</label>
				<div class="col-sm-10 layui-inline" style="float: left">
					<input name="need_items.purchaseDate" class="layui-input " placeholder="选择日期（必填）"  
					onclick="layui.laydate({elem: this, festival: true})">
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">生产厂家</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="need_items.vender" placeholder="必填" maxlength="50"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">保质期（年）</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="need_items.expirationDate" placeholder="必填" onkeyup="value=value.replace(/[\W]/g,'')" maxlength="3"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">经办人</label>
				<div class="col-sm-10" style="float: left">
					<input type="text" class="form-control" name="need_items.userName" placeholder="必填" maxlength="10"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">备注</label>
				<div class="col-sm-10" style="float: left">
					<textarea class="form-control" name="need_items.remark" placeholder="选填" maxlength="50"></textarea>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
		</div>
	</form>
</div>
<!-- 修改设备弹框 -->
<div id="updateNeedItemContent" hidden="hidden" >
	<form id="updateNeedItemform" action="#" method="post">
		<div class="col-xs-12">&nbsp;</div>
		<input id="items_id" name="items.id" type="text" hidden="hidden">
		<input id="needItems_id" name="need_items.id" type="text" hidden="hidden">
		<div class="col-xs-12">
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">设备名称</label>
				<div class="col-sm-10" style="float: left">
					<input id="items_name" type="text" class="form-control" name="items.name" placeholder="必填" maxlength="30" />
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">设备类别</label>
				<div class="col-sm-10" style="float: left">
					<input id="items_type" type="text" class="form-control" name="items.type" placeholder="必填" maxlength="30"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">设备型号</label>
				<div class="col-sm-10" style="float: left">
					<input id="items_modelNum" type="text" class="form-control" name="items.modelNum" placeholder="必填" maxlength="30"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">规格</label>
				<div class="col-sm-10" style="float: left">
					<input id="items_norms" type="text" class="form-control" name="items.norms" placeholder="必填" maxlength="30"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">单价（元）</label>
				<div class="col-sm-10" style="float: left">
					<input id="needItems_price" type="text" class="form-control" name="need_items.price" placeholder="必填" onkeyup="value=value.replace(/[\W]/g,'')" maxlength="6"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">需购数量</label>
				<div class="col-sm-10" style="float: left">
					<input id="needItems_number" type="text" class="form-control" name="need_items.number" placeholder="必填" onkeyup="value=value.replace(/[\W]/g,'')" maxlength="10"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">购置日期</label>
				<div class="col-sm-10 layui-inline" style="float: left">
					<input id="needItems_purchaseDate" name="need_items.purchaseDate" class="layui-input " placeholder="选择日期（必填）"  
					onclick="layui.laydate({elem: this, festival: true})">
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">生产厂家</label>
				<div class="col-sm-10" style="float: left">
					<input id="needItems_vender" type="text" class="form-control" name="need_items.vender" placeholder="必填" maxlength="50"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">保质期（年）</label>
				<div class="col-sm-10" style="float: left">
					<input id="needItems_expirationDate" type="text" class="form-control" name="need_items.expirationDate" placeholder="必填" onkeyup="value=value.replace(/[\W]/g,'')" maxlength="3"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">经办人</label>
				<div class="col-sm-10" style="float: left">
					<input id="needItems_userName" type="text" class="form-control" name="need_items.userName" placeholder="必填" maxlength="10"/>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
			<div class="col-xs-12">
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1">备注</label>
				<div class="col-sm-10" style="float: left">
					<textarea id="needItems_remark" class="form-control" name="need_items.remark" placeholder="选填" maxlength="50"></textarea>
				</div>
			</div>
			<div class="col-xs-12">&nbsp;</div>
		</div>
	</form>
</div>
<!-- 需购设备查看 -->
<script type="text/javascript">

getNeedItemsInfo(1); // 初始加载数据

/**
 * 获取需购设备信息
 */
function getNeedItemsInfo(curr) {
	var sTime = $("#LAY_demorange_s").val(); // 获取起始时间 
	var eTime = $("#LAY_demorange_e").val(); // 获取终止时间
	var needStatus = $("#status_select").val(); // 获取选择框的状态值
	var search = $("#search_input").val();  // 获取搜索框中信息
	$.post("need/getNeedItemsInfo", {"curr":curr,"size":10,"search":search,"sTime":sTime,"eTime":eTime,"needStatus":needStatus},
	function(resp) {
		pack(resp.list,curr);  // 填充表格数据
		laypage({  // 调用分页
			cont : $('#page5'), // 分页容器。
			pages : resp.totalPage, // 总页数
			skin : '#2283C5',//保持ace中间的样式
			first : 1,
			last : resp.totalPage, //总页数，将尾页显示为总页数
			curr : resp.pageNumber,//当前页
			groups : 5, //连续显示分页数
			jump : function(obj, first) {
				if (!first) { //一定要加此判断，否则初始时会无限刷新
					getNeedItemsInfo(obj.curr);
				}
			}
		});
	});
}
function pack(data,curr) { // 填充表格数据
	var dataStr = "";
	$.each(data, function(i, v) {
		dataStr += packlist(v,curr);
	});
	$("#itemsPage").html(dataStr);
}
function packlist(v,curr) { 
	var dataStr = "";
	dataStr += '<tr>';
	dataStr += '<td>' + v.name + '</td>';
	dataStr += '<td>' + v.type + '</td>';
	dataStr += '<td>' + v.modelNum + '</td>';
	dataStr += '<td>' + v.number + '</td>';
	dataStr += '<td>' + v.userName + '</td>';
	if(v.need_status==0){
		dataStr += '<td>待审核</td>';
	}else if(v.need_status==1){
		dataStr += '<td>通过</td>';
	}else if(v.need_status==-1){
		dataStr += '<td>驳回</td>';
	}else{
		dataStr += '<td>已购买</td>';
	}
	dataStr += '<td>' + v.purchaseDate + '</td>';
	dataStr += '<td> <div class="hidden-sm hidden-xs action-buttons">';
	dataStr += '<button class="layui-btn layui-btn-small" onclick="updateItemInfo('
		+ v.items_id + "," + curr + ')">详情/修改</button> ';
	
	dataStr += '<button class="layui-btn layui-btn-danger layui-btn-small"  onclick="delItemInfo('
		+ v.items_id + "," + curr + ')">删除</button>'; 
	if(v.need_status!=-2){
		dataStr += '<button class="layui-btn btn-success layui-btn-small"  onclick="buyItemInfo('
			+ v.items_id + "," + curr + ')">已购</button>'; 
	}
	dataStr += '</div> </td>';
	
	dataStr += '</tr>';
	return dataStr;
};

/**
 * 修改设备信息
 */
function updateItemInfo(itemsId,curr){
	$("#updateNeedItemform input").val(""); // 清空文本框数据
	// 填充弹框信息
	$.post("need/getNeedItemInfo", {"itemsId":itemsId}, function(resp) {
		$("#items_id").val(resp.items_id);
		$("#items_name").val(resp.name);
		$("#items_type").val(resp.type);
		$("#items_modelNum").val(resp.modelNum);
		$("#items_norms").val(resp.norms);
		$("#needItems_id").val(resp.need_id);
		$("#needItems_price").val(resp.price);
		$("#needItems_number").val(resp.number);
		$("#needItems_purchaseDate").val(resp.purchaseDate);
		$("#needItems_vender").val(resp.vender);
		$("#needItems_expirationDate").val(resp.expirationDate);
		$("#needItems_userName").val(resp.userName);
		$("#needItems_remark").val(resp.remark);
	});
	
	layer.open({
		type : 1,
		shade : [ 0.5 ],
		title : '修改需购设备', 
		area : [ '35%', '450px' ], //显示空间
		content : $('#updateNeedItemContent'), //捕获的元素
		btn : [ '确定', '取消' ],
		yes : function(index, layero) { 
			// validator验证
			$("#updateNeedItemform").submit();
			if(!update_validator.form()){
				return false;
			}			
			
			$.post("need/updateItemInfo", $("#updateNeedItemform").serialize(), function(resp) {
				if(resp=="success"){
					getNeedItemsInfo(curr);
					layer.msg("修改成功");
				}else{
					layer.msg("修改失败");
				}
				layer.close(index);
			});
		},
		cancel : function(index) {
			layer.close(index);
			layer.msg("取消");
		}, 
	});
}

/**
 * 删除设备信息
 */
function delItemInfo(itemsId,curr){
	layer.confirm("你确定删除吗？",{ btn:['确定','取消']}, function(){ 
		$.post("need/delItemInfo", {"itemsId":itemsId}, function(resp) {
			if(resp=="success"){
				getNeedItemsInfo(curr); // 刷新数据
				layer.msg("删除成功");
			}else{
				layer.msg("删除失败");
			}
		});	
	},function(){ 
		layer.msg("取消");
	});
}

/**
 * 更改设备状态
 */
function buyItemInfo(itemsId,curr){
	layer.confirm("你确定设备已购买吗？",{ btn:['确定','取消']}, function(){ 
		$.post("need/buyItemInfo", {"itemsId":itemsId}, function(resp) {
			if(resp=="success"){
				getNeedItemsInfo(curr); // 刷新数据
				layer.msg("修改成功");
			}else{
				layer.msg("修改失败");
			}
		});	
	},function(){ 
		layer.msg("取消");
	});
}

/**
 * 设备购买申请表下载
 */
function downloadNeedItemsWord() {
	var sTime = $("#LAY_demorange_s").val(); // 获取起始时间 
	var eTime = $("#LAY_demorange_e").val(); // 获取终止时间
	var needStatus = $("#status_select").val(); // 获取选择框的状态值
	var search = $("#search_input").val();  // 获取搜索框中信息
	var data = "search="+search+"&sTime="+sTime+"&eTime="+eTime+"&needStatus="+needStatus;
	window.location.href="need/downLoadWord?"+data;
}
</script>

<!-- 需购设备添加 -->
<script type="text/javascript">
/**
 * 添加需购设备
 */
function addNeedItem() {
	$("#addNeedItemform input").val(""); // 清空文本框数据
	layer.open({
		type : 1,
		shade : [ 0.5 ],
		title : '添加需购设备', 
		area : [ '38%', '450px' ], //显示空间
		content : $('#addNeedItemContent'), //捕获的元素
		btn : [ '确定', '取消' ],
		yes : function(index, layero) { //或者使用btn1
			// validator验证
			$("#addNeedItemform").submit();
			if(!add_validator.form()){
				return false;
			}
			
			$.post("need/addNeedItem", $("#addNeedItemform").serialize(), function(resp) {
				if(resp=="success"){
					getNeedItemsInfo(1); // 更新数据
					layer.msg("添加成功");
				}else{
					layer.msg("添加失败");
				}
				layer.close(index);
			});
		},
		cancel : function(index) {
			layer.close(index);
			layer.msg("取消");
		}, 
	});
};

/**
 * 下载模板文件
 */
function downloadTemplate(type){
	window.location.href="need/downloadTemplate?type="+type;
}

</script>
<!-- 表单验证 -->
<script type="text/javascript">

/* 添加表单验证 */
var add_validator = $("#addNeedItemform").validate({
	  submitHandler:function(form) {
			console.log("提交表单");
		},
	  errorPlacement: function(error, element) {
		  layer.msg(error[0].innerText);
	 	},
	 	onkeyup:false, // 敲键盘是不验证
		rules : {
			"items.name" : {
				required : true,
				maxlength : "30",
			},
			"items.type" : {
				required : true,
				maxlength : "30",
			},
			"items.modelNum" : {
				required : true,
				maxlength : "30",
			},
			"items.norms" : {
				required : true,
				maxlength : "30",
			},
			"need_items.price" : {
				required : true,
				maxlength : "10",
			},
			"need_items.number" : {
				required : true,
				maxlength : "10",
			},
			"need_items.purchaseDate" : {
				required : true,
			},
			"need_items.vender" : {
				required : true,
				maxlength : "50",
			},
			"need_items.expirationDate" : {
				required : true,
			},
			"need_items.userName" : {
				required : true,
				maxlength : "20",
			},
			"need_items.remark" : {
				maxlength : "50",
			},
		},
		messages : {
			"items.name" : {
				required : "请填写设备名称",
				maxlength : "长度不能超过30字符",
			},
			"items.type" : {
				required : "请填写设备类别",
				maxlength : "长度不能超过30字符",
			},
			"items.modelNum" : {
				required : "请填写设备型号",
				maxlength : "长度不能超过30字符",
			},
			"items.norms" : {
				required : "请填写设备规格",
				maxlength : "长度不能超过30字符",
			},
			"need_items.price" : {
				required : "请填写设备单价",
				maxlength : "长度不能超过10位",
			},
			"need_items.number" : {
				required : "请填写设备数量",
				maxlength : "长度不能超过10位",
			},
			"need_items.purchaseDate" : {
				required : "请选择购置日期",
			},
			"need_items.vender" : {
				required : "请填写生产厂家",
				maxlength : "长度不能超过50字符",
			},
			"need_items.expirationDate" : {
				required : "请填写设备保质期",
			},
			"need_items.userName" : {
				required : "请填写经办人姓名",
				maxlength : "长度不能超过20字符",
			},
			"need_items.remark" : {
				maxlength : "长度不能超过50字符",
			},
		}
	});
	
/* 修改表单验证 */
var update_validator = $("#updateNeedItemform").validate({
	  submitHandler:function(form) {
			console.log("提交表单");
		},
	  errorPlacement: function(error, element) {
		  layer.msg(error[0].innerText);
	 	},
	 	onkeyup:false, // 敲键盘是不验证
		rules : {
			"items.name" : {
				required : true,
				maxlength : "30",
			},
			"items.type" : {
				required : true,
				maxlength : "30",
			},
			"items.modelNum" : {
				required : true,
				maxlength : "30",
			},
			"items.norms" : {
				required : true,
				maxlength : "30",
			},
			"need_items.price" : {
				required : true,
				maxlength : "10",
			},
			"need_items.number" : {
				required : true,
				maxlength : "10",
			},
			"need_items.purchaseDate" : {
				required : true,
			},
			"need_items.vender" : {
				required : true,
				maxlength : "50",
			},
			"need_items.expirationDate" : {
				required : true,
			},
			"need_items.userName" : {
				required : true,
				maxlength : "20",
			},
			"need_items.remark" : {
				maxlength : "50",
			},
		},
		messages : {
			"items.name" : {
				required : "请填写设备名称",
				maxlength : "长度不能超过30字符",
			},
			"items.type" : {
				required : "请填写设备类别",
				maxlength : "长度不能超过30字符",
			},
			"items.modelNum" : {
				required : "请填写设备型号",
				maxlength : "长度不能超过30字符",
			},
			"items.norms" : {
				required : "请填写设备规格",
				maxlength : "长度不能超过30字符",
			},
			"need_items.price" : {
				required : "请填写设备单价",
				maxlength : "长度不能超过10位",
			},
			"need_items.number" : {
				required : "请填写设备数量",
				maxlength : "长度不能超过10位",
			},
			"need_items.purchaseDate" : {
				required : "请选择购置日期",
			},
			"need_items.vender" : {
				required : "请填写生产厂家",
				maxlength : "长度不能超过50字符",
			},
			"need_items.expirationDate" : {
				required : "请填写设备保质期",
			},
			"need_items.userName" : {
				required : "请填写经办人姓名",
				maxlength : "长度不能超过20字符",
			},
			"need_items.remark" : {
				maxlength : "长度不能超过50字符",
			},
		}
	});
</script>
<!-- 文件上传 -->
<script type="text/javascript">
jQuery(function($){
	try {
	  Dropzone.autoDiscover = false;
	  var myDropzone = new Dropzone("#dropzone" , {
	    paramName: "file", // 这个name会用来使用在上传使用 . 
	    maxFilesize: 1, // MB
	
		addRemoveLinks : false, //去除Remove链接
		dictDefaultMessage : //默认显示的字段
		'<span class="bigger-150 bolder"><i class="ace-icon fa fa-caret-right red"></i> 拖动文件</span> 到该上传区域 \
		<span class="smaller-80 grey">(或点击)</span> <br /> \
		<i class="upload-icon ace-icon fa fa-cloud-upload blue fa-3x"></i>',
		dictResponseError: '上传文件出现错误!',
		dictFallbackMessage:'你的浏览器不支持拖动上传!',
		dictFileTooBig:'文件太大({{filesize}}MB). 上传文件不能超过: {{maxFilesize}}MB.',
		dictResponseError:'服务器返回{{statusCode}}!',
		dictCancelUpload:'取消上传!',
		dictCancelUploadConfirmation:'取消这次上传?',
		dictRemoveFile:'移除文件',
		acceptedFiles:'.xls,.xlsx',
		dictInvalidFileType:'错误的文件类型!',
		dictMaxFilesExceeded:'你不能上传更多的文件了!',
		//改变这个previewTemplate 可以使用 Bootstrap 进度条
		previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n  <div class=\"dz-details\">\n    <div class=\"dz-filename\"><span data-dz-name></span></div>\n    <div class=\"dz-size\" data-dz-size></div>\n    <img data-dz-thumbnail />\n  </div>\n  <div class=\"progress progress-small progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n  <div class=\"dz-success-mark\"><span></span></div>\n  <div class=\"dz-error-mark\"><span></span></div>\n  <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>"
	  });
	} catch(e) {
		console.log("文件拖拽不支持版本过低的浏览器!");
	  //alert('Dropzone.js 不支持版本过低的浏览器!');
	}
});
</script>
<!-- 日期选择器 -->
<script type="text/javascript">
layui.use('laydate', function(){
  var laydate = layui.laydate;
  
  var start = {
    min: '1900-01-01 23:59:59'//laydate.now()
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,choose: function(datas){
      end.min = datas; //开始日选好后，重置结束日的最小日期
      end.start = datas //将结束日的初始值设定为开始日
    }
  };
  
  var end = {
    min: '1900-01-01 23:59:59'//laydate.now()
    ,max: '2099-06-16 23:59:59'
    ,istoday: false
    ,choose: function(datas){
      start.max = datas; //结束日选好后，重置开始日的最大日期
    }
  };
  
   document.getElementById('LAY_demorange_s').onclick = function(){
    start.elem = this;
    laydate(start);
  }
  document.getElementById('LAY_demorange_e').onclick = function(){
    end.elem = this
    laydate(end);
  } 
  
});
</script>